package com.xhwl.logistics.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Account;
import com.xhwl.common.pojo.cent.vehicle.VehcPayRecord;
import com.xhwl.common.query.cent.vehicle.PayRecordQuery;
import com.xhwl.logistics.converter.ToPage;
import com.xhwl.logistics.service.IVehcPayRecordService;
import com.xhwl.logistics.vo.VehiclePayRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lu.Aaron
 * @since 2021-08-16
 */
//已被VehiclePayRecordController替换使用（改用mybatis，sql语句写在mapper.xml中）
//@RestController
public class VehcPayRecordController {
    @Autowired
    private IVehcPayRecordService vehcPayRecordService;

    @Autowired
    private ToPage toPage;

    @ResponseBody
    @RequestMapping(value = "/pay-record/page/test", method = RequestMethod.POST)
    public ResultJson payRecordPage(@RequestBody PayRecordQuery payRecordQuery, Account account) {
        ResultJson resultJson = vehcPayRecordService.payRecordPage(payRecordQuery, account);

        Page<VehcPayRecord> page = (Page<VehcPayRecord>) resultJson.getResult();
        Page<VehiclePayRecordVO> vehiclePayRecordVOPage = toPage.toPageVehiclePayRecordVO(page);

        return ResultJson.success(vehiclePayRecordVOPage);
    }
    /**
     * 最近缴费
     * @return
     */

    @GetMapping(value = "/pay-record/recently")
    public ResultJson recently(Account account) {
        return vehcPayRecordService.recently(account);

    }
}

